//
//  UCWindowSetting.swift
//  UICreate
//
//  Created by 范晓鑫 on 2021/10/27.
//

import UIKit

extension UCSetting where TargetType: UIWindow {
    ///windowScene
    @available(iOS 13.0, *)
    public static func scene(_ scene:UIWindowScene?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.windowScene = scene
        })
    }
    ///canResizeToFitContent
    public static func fitContent(_ canResizeToFitContent:Bool = true) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.canResizeToFitContent = canResizeToFitContent
        })
    }
    ///screen
    public static func screen(_ screen:UIScreen) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.screen = screen
        })
    }
    ///windowLevel
    public static func level(_ level:UIWindow.Level) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.windowLevel = level
        })
    }
    ///rootViewController
    public static func root(_ controller:UIViewController?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.rootViewController = controller
        })
    }
}
